package util

import (
	"time"

	"github.com/fatih/structs"
	"github.com/satori/go.uuid"
)

// UUID 获取UUID
func UUID() string {
	return uuid.NewV4().String()
}

// StructToMap 转换struct为map
func StructToMap(s interface{}) map[string]interface{} {
	return structs.Map(s)
}

// UnixNanoFormat 纳秒时间戳格式化
func UnixNanoFormat(n int64) string {
	switch n {
	default:
		return time.Unix(n/1e9, 0).Format("2006-01-02 15:04:05 AM")
	case 0:
		return ""
	}
}
